<br>
<!--留言的展示-->

<% post.comments.forEach(function (comment) {%>
      <p><%= comment.name %>
          <span class="info"> 回复于 <%= comment.time %></span>
      </p>
      <p><%- comment.content %></p>
<%})%>
<!--添加留言的表单-->
<% if (user) { %>
<form method="post" action="/u/<%= post.name %>/<%= post.time.minute %>/<%= post.title %>">

     发布人<input type="hidden" name="name" value="<%= user.name %>" /><br />
    <textarea name="content" rows="5" cols="80"></textarea><br />
    <input type="submit" value="留言" />
</form>
<% } else { %>
<form method="post">
    回应请先登录或注
    <a href="/login">登陆</a>
    <a href="/reg">注册</a>
    <textarea name="content" rows="5" cols="80"></textarea>
</form>
<% } %>
<script>
    var textarea = document.querySelector('#tb');
    var button = document.querySelector('#sb');

    button.onclick = function (ev) {
        ev.preventDefault();
        alert('用户未登录，请先登录')
        location.href = '/login';
    }
    textarea.onclick = function () {
        alert('用户未登录，请先登录')
        location.href = '/login';
    }
    }

</script>